package com.gurun.camera.addDevice.model;

import com.danale.sdk.Danale;
import com.danale.sdk.platform.entity.deviceinfo.DeviceAddedOnlineInfoV4;
import com.danale.sdk.platform.result.deviceinfo.v4.DeviceAddedOnlineResultV4;

import java.util.Arrays;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by Administrator on 2016/9/19.
 */
public class CheckDevStatusModelImpl implements ICheckDevStatusModel {

    /**
     * Check the single device add status
     * @param deviceId
     * @return
     */
    @Override
    public Observable<DeviceAddedOnlineInfoV4> checkDeviceState(String deviceId) {
        return Danale.get().getPlatformDeviceInfoService().getDeviceAddedOnlineV4(1, Arrays.asList(new String[]{deviceId}),1,65535)
                .map(new Func1<DeviceAddedOnlineResultV4, DeviceAddedOnlineInfoV4>() {
                    @Override
                    public DeviceAddedOnlineInfoV4 call(DeviceAddedOnlineResultV4 deviceAddedOnlineResultV4) {
                        return deviceAddedOnlineResultV4.getDeviceAddedOnlineInfoList().get(0);
                    }
                });
    }
}
